<template>
	<view>
		<view class="policy_box">
			<view class="policy_list">
				<text class="" style="display: flex;justify-content: center;">{{data.policy_title}}</text>
			</view>
			<view class="policy_list" v-if="data.profit">
				<text class="policy_title">{{data.profit.profit.title}} [分润]</text>
				<view class="info_item">产品：
					<view class="">
						<text>{{data.product.name}}</text>
					</view>
				</view>
				<view class="info_item">费率：
					<view class="">
						<text v-for="(list,nmb) in data.profit.rate" :key="nmb">[{{list.name}}]</text>
					</view>
				</view>
				<view class="info_item">交易类型：
					<view class="">
						<text v-for="(list,nmb) in data.profit.tran" :key="nmb">[{{list.name}}]</text>
					</view>
				</view>
				<view class="info_item">卡类型：
					<view class="">
						<text v-for="(list,nmb) in data.profit.card" :key="nmb">[{{list.name}}]</text>
					</view>
				</view>
				<view class="info_item">收款方式：
					<view class="">
						<text v-for="(list,nmb) in data.profit.channel" :key="nmb">[{{list.name}}]</text>
					</view>
				</view>
				<view class="ha_setup_box" v-if="data.profit.setting.length > 0">
					<view class="ha_setup">
						<view class="ha_setup_list ha_setup_tit">
							<text>卡类型</text>
							<text>交易类型</text>
							<text>费率</text>
							<text>收款方式</text>
							<text>分润</text>
						</view>
						<view class="ha_setup_list" v-for="(item,index) in data.profit.setting" :key="index">
							<text>{{item.card}}</text>
							<text>{{item.tran}}</text>
							<text>{{item.rate}}</text>
							<text>{{item.channel}}</text>
							<text>{{item.value}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="policy_list" v-if="data.cash">
				<text class="policy_title">{{data.cash.cash.title}} [返现]</text>
				<view class="info_item">产品：
					<view class="">
						<text>{{data.product.name}}</text>
					</view>
				</view>
				<view class="info_item">费率：
					<view class="">
						<text v-for="(list,nmb) in data.cash.rate" :key="nmb">[{{list.name}}]</text>
					</view>
				</view>
				<view class="info_item">交易类型：
					<view class="">
						<text v-for="(list,nmb) in data.cash.tran" :key="nmb">[{{list.name}}]</text>
					</view>
				</view>
				<view class="info_item">卡类型：
					<view class="">
						<text v-for="(list,nmb) in data.cash.card" :key="nmb">[{{list.name}}]</text>
					</view>
				</view>
				<view class="info_item">收款方式：
					<view class="">
						<text v-for="(list,nmb) in data.cash.channel" :key="nmb">[{{list.name}}]</text>
					</view>
				</view>
				<view class="info_item">天数限制：
					<view class="">
						<text>{{data.cash.cash.day_limit}}</text>
					</view>
				</view>
				<view class="info_item">刷卡金额：
					<view class="">
						<text>{{data.cash.cash.money}}</text>
					</view>
				</view>
				<view class="info_item">奖励金额：
					<view class="">
						<text>{{data.cash.cash.reward}}</text>
					</view>
				</view>
			</view>
			<view class="policy_list" v-if="data.flow">
				<text class="policy_title">{{data.flow.flow.title}} [流量卡]</text>
				<view class="info_item">产品：
					<view class="">
						<text>{{data.product.name}}</text>
					</view>
				</view>
				<view class="info_item">奖励金额：
					<view class="">
						<text>{{data.flow.flow.reward}}</text>
					</view>
				</view>
			</view>
			<block v-if="data.standard">
				<view v-if="data.standard.length > 0">
					<view class="policy_list" v-for="(item,index) in data.standard" :key="index">
						<text class="policy_title">{{item.standard.title}} [达标]</text>
						<view class="info_item">产品：
							<view class="">
								<text>{{data.product.name}}</text>
							</view>
						</view>
						<view class="info_item">费率：
							<view class="">
								<text v-for="(list,nmb) in item.rate" :key="nmb">[{{list.name}}]</text>
							</view>
						</view>
						<view class="info_item">交易类型：
							<view class="">
								<text v-for="(list,nmb) in item.tran" :key="nmb">[{{list.name}}]</text>
							</view>
						</view>
						<view class="info_item">卡类型：
							<view class="">
								<text v-for="(list,nmb) in item.card" :key="nmb">[{{list.name}}]</text>
							</view>
						</view>
						<view class="info_item">收款方式：
							<view class="">
								<text v-for="(list,nmb) in item.channel" :key="nmb">[{{list.name}}]</text>
							</view>
						</view>
						<view class="info_item">天数限制：
							<view class="">
								<text>{{item.standard.day_limit}}</text>
							</view>
						</view>
						<view class="info_item">刷卡金额：
							<view class="">
								<text>{{item.standard.money}}</text>
							</view>
						</view>
						<view class="info_item">奖励金额：
							<view class="">
								<text>{{item.standard.reward}}</text>
							</view>
						</view>
					</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: null,
				data: {}
			}
		},
		onLoad(e) {
			this.id = e.id
			this.policy_info()
		},
		methods: {
			async policy_info() {
				uni.showLoading({
					title: '加载中'
				});
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'setting/getPolicyDetails',
					data: {
						policy_id: this.id
					},
					header: {
						'token': userinfo.token
					},
				});
				if (res.code == 1) {
					this.data = res.data
					uni.hideLoading()
				} else {
					uni.showToast({
						title: res.msg,
						duration: 2000,
						icon: 'none',
					});
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.info_item {
		margin-top: 15rpx;
		font-size: 28rpx;
		display: flex;
		justify-content: space-between;

		view {
			width: 70%;
			text-align: right;
			display: flex;
			justify-content: flex-end;
			flex-wrap: wrap;
		}
	}

	.policy_box {
		padding: 30rpx;
		box-sizing: border-box;

		.policy_list {
			padding: 20rpx;
			border-radius: 15rpx;
			box-shadow: 0px 1px 14px -10px #999;
			margin-bottom: 30rpx;

			.policy_standard {
				margin-bottom: 30rpx;
			}

			.policy_standard:not(:first-child) {
				margin-top: 20rpx;
				padding-top: 20rpx;
				border-top: #bcbcbc 1px solid;
			}

			.policy_title {
				border-bottom: #ebebeb dotted 1px;
				width: 100%;
				display: block;
				padding: 0 0 20rpx 0;
				margin-bottom: 20rpx;
				font-size: 28rpx;
				color: #333;
			}

			.policy_item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 10rpx;

				text {
					font-size: 24rpx;
					color: #999;
				}
			}
		}
	}

	.ha_setup_box {
		padding: 30rpx;
		margin-top: 30rpx;
		border-top: #333 1px solid;

		.ha_setup {
			.ha_setup_list {
				margin-bottom: 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				text {
					display: block;
					text-align: center;
					font-size: 24rpx;
					flex: 1;
				}
			}

			.ha_setup_tit {
				border-bottom: #eee 1px solid;
				padding-bottom: 20rpx;
			}
		}
	}
</style>